#include <dht11.h>

dht11 DHT11;
#define DHT11PIN 3
int illuPin = A1;
float illuVal = 0;
float temp;
float hum;
long start = millis();

void setup() {
  Serial.begin(9600);
}

String formatData(float t, float h, float i) {
  String data = "{" + String(t) + "," + String(h) + "," + String(i) + "}";
  return data;
}

void loop() {
  if (DHT11.read(DHT11PIN) == DHTLIB_OK) { //温湿度传感器正常工作
    temp = (float)DHT11.temperature;
    hum = (float)DHT11.humidity;
  } else {
    temp = 0;
    hum = 0;
  }
  illuVal = analogRead(illuPin);  //获取光照强度
  Serial.println(formatData(temp, hum, illuVal));
  delay(1000);
}
